from enum import Enum


class Direction(Enum):
    """
    Direction of order/trade/position.
    """
    LONG = "LONG"
    SHORT = "SHORT"
    NET = "NET"
    UNDEFINED = "UNDEFINED"


class WidenAlertType(Enum):
    COIN_INVENTORY_INSUFFICIENT = "COIN_INVENTORY_INSUFFICIENT"
    USDT_INVENTORY_INSUFFICIENT = "USDT_INVENTORY_INSUFFICIENT"
    BBO_OUT_OF_DATE = "BBO_OUT_OF_DATE"
    PUBLIC_TRADE_OUT_OF_DATE = "PUBLIC_TRADE_OUT_OF_DATE"


class AbnormalAlertType(Enum):
    COIN_INVENTORY_INSUFFICIENT = "COIN_INVENTORY_INSUFFICIENT"
    USDT_INVENTORY_INSUFFICIENT = "USDT_INVENTORY_INSUFFICIENT"
    BBO_OUT_OF_DATE = "BBO_OUT_OF_DATE"
    PUBLIC_TRADE_OUT_OF_DATE = "PUBLIC_TRADE_OUT_OF_DATE"
    TOO_MANY_OPEN_ORDERS = "TOO_MANY_OPEN_ORDERS"
    TOO_MANY_ORDER_REJECTION = "TOO_MANY_ORDER_REJECTION"


class EmptyList(Enum):
    INSERT_BUY = "insert_buy"
    INSERT_SELL = "insert_sell"
    CANCEL_BUY = "cancel_buy"
    CANCEL_SELL = "cancel_sell"


class Offset(Enum):
    """
    Offset of order/trade.
    """
    NONE = ""
    OPEN = "开"
    CLOSE = "平"
    CLOSETODAY = "平今"
    CLOSEYESTERDAY = "平昨"


class Status(Enum):
    """
    Order status.
    """
    SUBMITTING = "SUBMITTING"
    PENDING = "PENDING"
    NOTTRADED = "NOTTRADED"
    PARTTRADED = "PARTTRADED"
    ALLTRADED = "ALLTRADED"
    CANCELLED = "CANCELLED"
    REJECTED = "REJECTED"
    CANCELLING = "CANCELLING"
    UNKNOWN = "UNKNOWN"
    FAILED = "FAILED"


class PosType(Enum):
    LOCAL = "LOCAL"
    EXCHANGE = "EXCHANGE"


class StopOrderStatus(Enum):
    WAITING = "等待中"
    CANCELLED = "已撤销"
    TRIGGERED = "已触发"
    REJECTED = "条件单拒绝"
    REDUCE = "减仓"


class Channel(Enum):
    DEPTH1 = "DEPTH1"
    DEPTH20 = "DEPTH20"
    FUNDINGRATE = "FUNDING_RATE"
    MBP = "MBP"


class Product(Enum):
    """
    Product class.
    """
    EQUITY = "股票"
    FUTURES = "期货"
    OPTION = "期权"
    INDEX = "指数"
    FOREX = "外汇"
    ETF = "ETF"
    BOND = "债券"
    WARRANT = "权证"
    SPREAD = "价差"
    FUND = "基金"
    USWAP = "USDT-SWAP"
    CSWAP = "COIN-SWAP"
    SPOT = "SPOT"


class OrderType(Enum):
    """
    Order type.
    """
    LIMIT = "限价"
    MARKET = "市价"
    STOP = "STOP"
    FAK = "FAK"
    FOK = "FOK"
    RFQ = "询价"
    TAKE_PROFIT_MARKET = "市价止赢"
    TAKE_PROFIT = "止盈单"
    STOP_LOSS = "止损单"
    STOP_LOSS_LIMIT = "限价止损单"
    MAKER = "做市"
    ERROR = "占位符"


class ApiSource(Enum):
    """
    Api Source
    """
    SEND = "下单"
    CANCEL = "撤单"
    QUERY = "查询"
    WEBSOCKET = "WEBSOCKET"
    REST = "REST"
    QUERYOPEN = "QUERYOPEN"
    RECOVERY = "RECOVERY"
    ERROR = "占位"


class OptionType(Enum):
    """
    Option type.
    """
    CALL = "看涨期权"
    PUT = "看跌期权"


class Exchange(Enum):
    """
    Exchange.
    """
    # Chinese
    CFFEX = "CFFEX"  # China Financial Futures Exchange
    SHFE = "SHFE"  # Shanghai Futures Exchange
    CZCE = "CZCE"  # Zhengzhou Commodity Exchange
    DCE = "DCE"  # Dalian Commodity Exchange
    INE = "INE"  # Shanghai International Energy Exchange
    SSE = "SSE"  # Shanghai Stock Exchange
    SZSE = "SZSE"  # Shenzhen Stock Exchange
    SGE = "SGE"  # Shanghai Gold Exchange
    WXE = "WXE"  # Wuxi Steel Exchange
    CFETS = "CFETS"  # China Foreign Exchange Trade System

    # Global
    SMART = "SMART"  # Smart Router for US stocks
    NYSE = "NYSE"  # New York Stock Exchnage
    NASDAQ = "NASDAQ"  # Nasdaq Exchange
    ARCA = "ARCA"  # ARCA Exchange
    EDGEA = "EDGEA"  # Direct Edge Exchange
    ISLAND = "ISLAND"  # Nasdaq Island ECN
    BATS = "BATS"  # Bats Global Markets
    IEX = "IEX"  # The Investors Exchange
    NYMEX = "NYMEX"  # New York Mercantile Exchange
    COMEX = "COMEX"  # COMEX of CME
    GLOBEX = "GLOBEX"  # Globex of CME
    IDEALPRO = "IDEALPRO"  # Forex ECN of Interactive Brokers
    CME = "CME"  # Chicago Mercantile Exchange
    ICE = "ICE"  # Intercontinental Exchange
    SEHK = "SEHK"  # Stock Exchange of Hong Kong
    HKFE = "HKFE"  # Hong Kong Futures Exchange
    HKSE = "HKSE"  # Hong Kong Stock Exchange
    SGX = "SGX"  # Singapore Global Exchange
    CBOT = "CBT"  # Chicago Board of Trade
    CBOE = "CBOE"  # Chicago Board Options Exchange
    CFE = "CFE"  # CBOE Futures Exchange
    DME = "DME"  # Dubai Mercantile Exchange
    EUREX = "EUX"  # Eurex Exchange
    APEX = "APEX"  # Asia Pacific Exchange
    LME = "LME"  # London Metal Exchange
    BMD = "BMD"  # Bursa Malaysia Derivatives
    TOCOM = "TOCOM"  # Tokyo Commodity Exchange
    EUNX = "EUNX"  # Euronext Exchange
    KRX = "KRX"  # Korean Exchange
    OTC = "OTC"  # OTC Forex Broker
    IBKRATS = "IBKRATS"  # Paper Trading Exchange of IB

    # CryptoCurrency
    BITMEX = "BITMEX"
    OKX = "OKX"
    HUOBI = "HUOBI"
    BITFINEX = "BITFINEX"
    BINANCE = "BINANCE"
    BYBIT = "BYBIT"  # bybit.com
    COINBASE = "COINBASE"
    DERIBIT = "DERIBIT"
    GATEIO = "GATEIO"
    BITSTAMP = "BITSTAMP"
    FTX = "FTX"
    XT = "XT"
    ZB = "ZB"
    MEXC = "MEXC"
    KUCOIN = "KUCOIN"
    BTSE = "BTSE"

    # DEX
    UNISWAP = "UNISWAP"
    # Special Function
    LOCAL = "LOCAL"  # For local generated data

    # UNDEFINED
    UNDEFINED = "UNDEFINED"


class Currency(Enum):
    """
    Currency.
    """
    USD = "USD"
    HKD = "HKD"
    CNY = "CNY"


class Interval(Enum):
    """
    Interval of bar data.
    """
    MINUTE = "1m"
    HOUR = "1h"
    DAILY = "d"
    WEEKLY = "w"
    SECOND = "1s"
    TICK = "tick"


class BinanceContractType(Enum):
    """
    币安合约类型
    """
    PERPETUAL = "永续合约"
    CURRENT_MONTH = "当月交割合约"
    NEXT_MONTH = "次月交割合约"
    CURRENT_QUARTER = "当季合约"
    NEXT_QUARTER = "次季合约"
    CURRENT_QUARTER_DELIVERING = "当季交割中的无效类型"
    NEXT_QUARTER_DELIVERING = "次季交割中的无效类型"
    CURRENT_MONTH_DELIVERING = "当月交割中的无效类型"
    NEXT_MONTH_DELIVERING = "次月交割中的无效类型"
